import request from '@/utils/request'

// 搜索售货机(售货机列表)
export const getSearch = (data) => request.get('/api/vm-service/vm/search', {
  params: { ...data }
})

// 售货机类型列表(搜索)
export const getTypeSearch = (data) => request.get('/api/vm-service/vmType/search', {
  params: { ...data }
})

// 获取一定时间范围之内的订单总数
export const getOrderCount = (data) => request.get('/api/order-service/report/orderCount', {
  params: { ...data }
})

// 获取一定时间范围之内的收入
export const getOrderAmount = (data) => request.get('/api/order-service/report/orderAmount', {
  params: { ...data }
})

// 获取售货机补货次数
export const getSupplyCount = (data) => request.get(`/api/task-service/task/supplyCount/${data.innerCode}/${data.start}/${data.end}`)

// 获取售货机维修次数
export const getRepairCount = (data) => request.get(`/api/task-service/task/repairCount/${data.innerCode}/${data.start}/${data.end}`)

// 获取售货机商品销量
export const getSkuCollect = (data) => request.get(`/api/order-service/report/skuCollect/${data.innerCode}/${data.start}/${data.end}`)

// 售货机类型修改
export const getVmType = (data) => request.put(`/api/vm-service/vmType/${data.typeId}`, data)

// 图片上传
export const setFileUpload = (data) => request.post('/api/vm-service/sku/fileUpload', data)

// 点位搜索
export const getNodeSearch = () => request.get('/api/vm-service/node/search', {
  params: {
    pageIndex: 1,
    pageSize: 100000
  }
})

// 修改售货机点位
export const getVmService = (data) => request.put(`/api/vm-service/vm/${data.id}/${data.nodeId}`)

// 新增售货机
export const addVmService = (data) => request.post('/api/vm-service/vm', data)

// 查询售货机策略
export const getVmPolicy = (innerCode) => request.get(`/api/vm-service/policy/vmPolicy/${innerCode}`)

// 策略列表
export const getPolicyList = () => request.get('/api/vm-service/policy')

// 取消策略
export const putCancelPolicy = (innerCode, policyId) => request.put(`/api/vm-service/vm/cancelPolicy/${innerCode}/${policyId}`)

// 应用策略
export const putApplyPolicy = (data) => request.put('/api/vm-service/vm/applyPolicy', data)

// 售货机类型详情
export const getVmTypet = (typeId) => request.get(`/api/vm-service/vmType/${typeId}`)

// 获取售货机货道详情
export const getChannelList = (innerCode) => request.get(`/api/vm-service/channel/channelList/${innerCode}`)

// 商圈列表
export const getBusinessType = (id) => request.get(`/api/vm-service/businessType/name/${id}`)

// 获取商圈下销量前十的商品
export const getBusinessTop = (businessId) => request.get(`/api/vm-service/sku/businessTop10/${businessId}`)

// 商品搜索
export const getSkuSearch = () => request.get('/api/vm-service/sku/search', {
  params: {
    pageIndex: 1,
    pageSize: 100000
  }
})

// 商品名搜索
export const getSearchGoods = (goodsName) => request.get('/api/vm-service/sku/search', {
  params: {
    pageIndex: 1,
    pageSize: 100000,
    skuName: goodsName
  }
})

// 货物配置
export const putChannelConfig = (data) => request.put('/api/vm-service/channel/channelConfig', data)

// 新增售货机类型
export const addVmType = (data) => request.post('/api/vm-service/vmType', data)
